]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
gdm/authPrompt: Preserve the text when switching entry visibility
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Mon, 25 Aug 2025 12:35:57 +0000 (14:35 +0200)
committerMarge Bot <marge-bot@gnome.org>
Sat, 30 Aug 2025 01:36:14 +0000 (01:36 +0000)
The text visibility of an auth prompt entry may change dynamically at
runtime, in particular when unlocking the screen with the blank screen
or with the screen shield visible this is happening:
 - The user starts typing the PAM credential (may be secret or not)
 - Under the hood the PAM conversation starts and actually asks user
   for input
 - The entry text is not cleared because we use what the user has typed
   so far as the preemptive secret.
 - The entry is adjusted to follow the requested PAM text visibility
   settings.
   -> This may lead to switching the actual text entry widget in use

Now, if the first entry that PAM requires is "ECHO ON", like it may
happen in the case in which a visible value is requested, we end up
"clearing" what the user as typed instead of preserving the value as
pre-filled value.

Causing the user typing something wrong instead.

To prevent this we need to restore both the text, the cursor position
and the selection bounds (in case the use pressed some key [binding])
leading to a position or selection change.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3850>

js/gdm/authPrompt.js

index b6fdb65e901a85bf9dc29bb434cd82e67b7fe84b..b9d35354ffdfd73c20e9beea9b5f90e71747d428 100644 (file)
@@ -307,6 +307,9 @@ export const AuthPrompt = GObject.registerClass({
             this._mainBox.replace_child(this._entry, newEntry);
             this._entry = newEntry;
             this._inactiveEntry = inactiveEntry;
+
+            const {text, cursorPosition, selectionBound} = inactiveEntry.clutterText;
+            this._entry.clutterText.set({text, cursorPosition, selectionBound});
         }
 
         this._capsLockWarningLabel.visible = secret;